﻿using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Text;

namespace Bot.Salesforce.Extension
{
    public static class HttpRequestMessageExtensions
    {
        public static HttpRequestMessage AddContent(this HttpRequestMessage request, string content)
        {
            request.Content = new StringContent(content, Encoding.UTF8, "application/json");
            return request;
        }

        public static HttpRequestMessage AddAuthorization(this HttpRequestMessage request, string token)
        {
            request.Headers.Add("Authorization", $"Bearer {token}");
            return request;
        }

        public static HttpRequestMessage AddForm(this HttpRequestMessage request, IEnumerable<KeyValuePair<string, string>> nameValueCollection)
        {
            request.Content = new FormUrlEncodedContent(nameValueCollection);
            return request;
        }
    }
}
